<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>div水平垂直居中</title>
  <style>
    .table{
      height: 100px;
    }
    .table div{
      text-align: center; /* 文字水平居中 */
      height: 100px;
      width: 100px;
      line-height: 100px; /* 文字垂直居中: 高度跟height一样的时候, 就垂直居中了(仅限单行) */
      border: 1px solid #000;
      float: left;
    }
    .zui div:hover {
      background-color: #ccc;
    }
  </style>
</head>
<body>
  <div class="table">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
  </div>
</body>
</html>